/*
 * Niiuzu
 * Copyright (C) 2011  Thierry Nowak
 * 
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.niiuzu.client.screen.authentification.lost.password;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import com.niiuzu.client.util.view.AbstractPopupView;

/**
 * Implémentation de la vue du mot de passe perdu.
 */
public class LostPasswordViewImpl extends AbstractPopupView implements
		LostPasswordView {

	/**
	 * Interface {@link UiBinder} adaptée à la vue {@link LostPasswordViewImpl}.
	 */
	interface SuitedUiBinder extends UiBinder<Widget, LostPasswordViewImpl> {

	}

	@UiField
	HasClickHandlers closeButton;
	@UiField
	HasClickHandlers cancelAnchor;
	@UiField
	HasClickHandlers validateButton;

	@UiField
	TextBox emailField;
	@UiField
	TextBox emailConfirmationField;

	@Override
	public void createView() {
		SuitedUiBinder uiBinder = GWT.create(SuitedUiBinder.class);
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public void focusEmailAddressField() {
		emailField.setFocus(true);
	}

	@Override
	public HasClickHandlers getCancelHasClickHandlers() {
		return cancelAnchor;
	}

	@Override
	public HasClickHandlers getCloseButtonHasClickHandlers() {
		return closeButton;
	}

	@Override
	public HasValue<String> getEmailAddressConfirmationField() {
		return emailConfirmationField;
	}

	@Override
	public HasValue<String> getEmailAddressField() {
		return emailField;
	}

	@Override
	public HasClickHandlers getValidationHasClickHandlers() {
		return validateButton;
	}

	@Override
	public void showConfirmationMessage(String message) {
		Window.alert(message);
	}
}
